package com.fannuo.demo.Util;

import com.alibaba.fastjson.JSONObject;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;

public class FileUtil {
    public static List<JSONObject> getJSONList(File file) throws IOException {
        List<JSONObject> list = new ArrayList<>();
        if(file.exists()){
            BufferedReader br = new BufferedReader(new InputStreamReader(Files.newInputStream(file.toPath()), StandardCharsets.UTF_8));
            String temp;
            while((temp = br.readLine()) != null){
                list.add(JSONObject.parseObject(temp));
            }
        }
        return list;
    }
}
